﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="edit.aspx.cs" Inherits="new_edit"
    ValidateRequest="false" %>

<%@ Register Src="~/news/NewsTypeSelect.ascx" TagPrefix="uc1" TagName="NewsTypeSelect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../edit/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../edit/xheditor-zh-cn.src.js"></script>
    <script src="../js/jquery.autocomplete.js" type="text/javascript"  language="javascript"></script>
    <script src="../js/StockSearchData.js" language="javascript" type="text/javascript"></script>
    <script type="text/javascript" defer="defer" src="../My97DatePicker/WdatePicker.js"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js"></script>
    <script type="text/javascript" language="javascript">
        var selectValue = new Array();
        $(pageInit);
        function pageInit() {
            $('#txtSummary,').xheditor();
            $("#txtContent").xheditor({ upImgUrl: "../upload/newsUpload.aspx", upImgExt: "jpg,jpeg,gif,png" })
        }
        function submitForm() { $("frmDemo").submit(); }
        $(document).ready(function () {
            $("#txtStock").autocomplete(EALists, {
                max: 10,
                minChars: 0,
                width: 160,
                matchContains: true,
                autoFill: false,
                formatItem: function (row, i, max) {
                    return row._C + " " + row._S + " " + row._N;
                },
                formatMatch: function (row, i, max) {
                    return row._C + " " + row._S + " " + row._N;
                },
                formatResult: function (row) {
                    return row._C;
                }
            });
            function insertUpload(msg) {
                msg = msg[0];
                $("#uploadList").append('<option value="' + msg.id + '">' + msg.localname + '</option>');
            }

            $("#btnSelect").click(function () {
                var cbklist = $("#DataList1 input[type=checkbox]");
                var vals = $("#hidSelectValue").val().split(",");

                for (var i = 0; i < vals.length; i++) {
                    for (var j = 0; j < cbklist.length; j++) {
                        if (cbklist[j].value == vals[i]) {
                            cbklist[j].checked = true;
                        }
                    }
                }
                selectValue.length = 0;
                for (var i = 0; i < cbklist.length; i++) {
                    if (cbklist[i].checked) {
                        selectValue[selectValue.length] = $(cbklist[i]).val();
                    }
                }
                $("#dialog").dialog('open');
            })

            $("#btnClearUrl").click(function () {
                var content = $("#txtContent").val();
                var rega = /\s/;
                while (rega.test(content)) {
                    content = content.replace(rega, "<br/>");
                }
                $("#txtContent").val(content);
                return false;
            })

            $("#dialog").dialog({
                autoOpen: false,
                width: 800,
                buttons: {
                    "取消": function () {
                        var cbklist = $("#DataList1 input[type=checkbox]");
                        for (var i = 0; i < cbklist.length; i++) {
                            cbklist[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (cbklist[i].value == selectValue[j]) {
                                    cbklist[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var cbklist = $("#DataList1 input[type=checkbox]");
                        var list = "";
                        var x = "";
                        $("#lblSelectType").html('');
                        for (var i = 0; i < cbklist.length; i++) {
                            if (cbklist[i].checked) {
                                list += $(cbklist[i]).parent().children("Label").html() + ",";
                                x += $(cbklist[i]).val() + ",";
                            }
                        }
                        if (x.length == 0) {
                            alert("必须选择一个新闻类型");
                            return;
                        }
                        if (list.length > 0) {
                            list = list.substring(0, list.length - 1);
                        }

                        x = x.substring(0, x.length - 1);
                        $("#hidSelectValue").val(x);

                        $("#lblSelectType").html(list);
                        $(this).dialog("close");
                    }
                }
            })
        })

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div class="button_bar">
          <asp:Button ID="btnBack" CssClass="common_button" runat="server" Text="返回" 
              onclick="btnBack_Click" ValidationGroup="22" />
        <asp:Button ID="btnSave" CssClass="common_button" runat="server" Text="保存" OnClick="btnSave_Click" />
    </div>
    <div>
        <table class="query_form_table">
            <tr>
                <th>
                    新闻类型
                </th>
                <td colspan="3">
                    <asp:HiddenField ID="hidNewType" runat="server" />
                    <asp:Label ID="lblSelectType" runat="server" />
                    <input value="选择" id="btnSelect" type="button" class="common_button" />
                </td>
            </tr>
            <tr>
                <th>
                    标题 <span style="color:Red">*</span>
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtTitle" runat="server" Width="465px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTitle"
                        Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    新闻编号
                </th>
                <td>
                    <asp:TextBox ID="txtNewsId" runat="server" ReadOnly="true" />
                </td>
                <th>
                    新闻来源
                </th>
                <td>
                    <asp:TextBox ID="txtSource" runat="server" />
                </td>
            </tr>
            <tr>
                <th>
                    作者
                </th>
                <td>
                    <asp:TextBox ID="txtAuthor" runat="server" />
                </td>
                <th>
                    相关股票
                </th>
                <td>
                    <asp:TextBox ID="txtStock" runat="server"  />
                    (000001,000002)</td>
            </tr>
            <tr>
                <th>
                    是否发布
                </th>
                <td>
                    <asp:RadioButton ID="rdoEnableYes" runat="server" value="1" Text="是" Checked="true"
                        GroupName="aa" />
                    <asp:RadioButton ID="rdoEnableNo" runat="server" Text="否" value="0" GroupName="aa" />
                </td>
                <th>发布时间</th>
                <td>
                    <asp:TextBox ID="txtPTime" runat="server" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" />
                </td>
            </tr>
            <tr>
             <th>
                    新闻重要度
                </th>
                <td>
                    <asp:DropDownList ID="ddlStep" runat="server">
                        <asp:ListItem Value="0">0</asp:ListItem>
                        <asp:ListItem Value="1">1</asp:ListItem>
                        <asp:ListItem Value="2">2</asp:ListItem>
                        <asp:ListItem Value="3">3</asp:ListItem>
                        <asp:ListItem Value="4">4</asp:ListItem>
                        <asp:ListItem Value="5">5</asp:ListItem>
                        <asp:ListItem Value="6">6</asp:ListItem>
                    </asp:DropDownList>
                </td>
               <th>
                新闻属性
            </th>
            <td>
                <asp:DropDownList ID="ddlNature" runat="server">
                    <asp:ListItem Value="0">中性</asp:ListItem>
                    <asp:ListItem Value="1">利多</asp:ListItem>
                    <asp:ListItem Value="2">利空</asp:ListItem>
                </asp:DropDownList>
            </td>
            </tr>
            <tr>
                <th>
                    关键字  <span style="color:Red">*</span>
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtKeyWords" runat="server" Width="382px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtKeyWords"
                        Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    标题图片</th>
                <td colspan="3">
                    <asp:Image ID="Image1" runat="server" />
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                    <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="上传图片" 
                        ValidationGroup="ccc" />
                </td>
            </tr>
            <tr>
                <th>
                    外部链接
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtOutsideUrl" runat="server" Width="382px" />
                </td>
            </tr>
            <tr>
                <th>
                    摘要
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtSummary" runat="server" Width="80%" Height="113px" TextMode="MultiLine" />
                </td>
            </tr>
            <tr>
                <th>
                    内容
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtContent" runat="server" Width="80%" Height="300px" TextMode="MultiLine" />
                    <br />
                 <asp:Button ID="btnClearUrl" runat="server" Text="文本换行" />
                </td>
            </tr>
        </table>
    </div>
    <div class="button_bar">
        <asp:Button ID="btnBack1" CssClass="common_button" runat="server" Text="返回" 
            onclick="btnBack_Click" ValidationGroup="22" />
        <asp:Button ID="Button2" CssClass="common_button" runat="server" Text="保存" OnClick="btnSave_Click" />
    </div>
    <div id="dialog" title="提示消息">
        <div style="overflow-y:auto; height:450px">
        <p id="content" style="text-align: center">
            <asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound"
                RepeatDirection="Horizontal" RepeatColumns="1">
                <ItemTemplate>
                    <uc1:NewsTypeSelect ID="NewsTypeSelect1" runat="server" Pid='<%# Eval("id") %>' />
                </ItemTemplate>
            </asp:DataList>
        </p>
        </div>
    </div>
    </form>
</body>
</html>
